package com.zyz.K_集合.Iterator迭代器;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class TestIterator2 {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
        collection.add(111);
        collection.add(222);
        collection.add("vick");
        collection.add("aaa");
        Iterator iterator = collection.iterator();
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());
        System.out.println(iterator.next());

        System.out.println("=====");
        Iterator iterator1 = collection.iterator();//回到起点
        while (iterator1.hasNext()) {
            System.out.println(iterator1.next());
        }
    }
}
